package com.etoak.api;

import com.etoak.common.core.vo.ResultVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * 远程服务接口
 * http://upload-service/upload/image
 */
@FeignClient("upload-service")
public interface UploadService {

    /**
     * 调用远程服务的文件上传接口
     * 1、@PostMapping 必须设置 consumes 属性, consumes="multipart/form-data"
     * 2、MultipartFile 参数前必须使用注解 @RequestPart
     */
    @PostMapping(value = "/upload/image", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    ResultVO<String> upload(@RequestPart MultipartFile pic) throws IOException;
}
